<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org"
      xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head th:include="include :: header"></head>
<body class="hold-transition skin-blue sidebar-mini">

<section class="content-header">
    <h1>员工业绩查询</h1>
</section>
<section class="content">
    <div class="row">
        <div class="col-xs-12">
            <div class="box">
                <div class="box-header">
                    <form id="queryForm" onsubmit="return false;">
                        <div class="row">
                            <div class="form-inline">
                                <div class="form-group">
                                    <label for="query-taskerName">员工</label>
                                    <input id="query-taskerName" type="text" name="taskerName" class="form-control"
                                           placeholder="请输入员工姓名">
                                </div>
                                <div class="form-group">
                                    <label for="query-deptName">设计科室</label>
                                    <input id="query-deptName" type="text" name="deptName" class="form-control"
                                           placeholder="请输入设计科室">
                                </div>
                                <div class="form-group">
                                    <label for="query-startTime">日期</label>
                                    <input id="query-startTime" type="text" class="form-control datepicker"
                                           name="startTime"
                                           readonly="readonly"/>
                                    <label for="query-endTime"> 至 </label>
                                    <input id="query-endTime" type="text" class="form-control datepicker" name="endTime"
                                           readonly="readonly"/>
                                </div>
                                <button type="button" class="btn btn-success" id="btn-search"
                                        onclick="js.table.search(table)">
                                    <span class="Bold">搜索</span>
                                </button>
                            </div>
                        </div>
                    </form>
                </div>
                <div class="box-body">
                    <table id="bootstrap-table"></table>
                </div>
            </div>
        </div>
    </div>
</section>
<div th:include="include :: footer"></div>
<script th:inline="javascript">

    let table;

    $(function () {

        table = js.table.init({
            url: ctx + "craft/EmployeeQuery/gantWork",
            detailView: true,
            onExpandRow: function (index, row, $detail) {
                initChildTable(index, row, $detail);
            },
            columns: [
                {
                    title: '序号', width: '50',
                    formatter: function (value, row, index) {
                        return index + 1;
                    }
                },
                {title: "员工", field: 'taskerName', width: '150'},
                {title: "项目编号", field: 'proCode', width: '150'},
                {title: "项目名称", field: 'proName'},
                {title: "开始时间", field: 'startTime', width: '180'},
                {title: "结束时间", field: 'endTime', width: '180'},
                {title: "总历时（天）", field: 'allDiachronic', width: '130'}
            ]
        });
    });

    initChildTable = function (index, row, $detail) {
        let childTable = $detail.html('<table style="table-layout:fixed"></table>').find('table');
        $(childTable).bootstrapTable({
            url: ctx + "craft/EmployeeQuery/gantWorkDetail",
            method: 'post',
            sidePagination: "server",
            contentType: "application/x-www-form-urlencoded",
            queryParams: {
                proCode: row.proCode,
                taskerName: row.taskerName
            },
            responseHandler: function (res) {
                if (res.type === "SUCCESS") {
                    return res.data;
                }
                js.modal.warning(res.msg);
                return {rows: [], total: 0};
            },
            columns: [
                {
                    title: '序号', width: '50',
                    formatter: function (value, row, index) {
                        return index + 1;
                    }
                },
                {
                    field: 'content',
                    title: '任务内容'
                },
                {
                    field: 'startTime',
                    title: '开始时间'
                },
                {
                    field: 'endTime',
                    title: '结束时间'
                },
                {
                    field: 'remark',
                    title: '备注'
                },
                {
                    field: 'diachronic',
                    title: '历时（天）'
                }
            ]
        });
    };
</script>
</body>
</html>
